home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
051-075
/
disk_052
/
tek4010
/
defaults.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-05-06
|
3KB
|
107 lines
/***************************************************************
* vt100 - terminal emulator - initialization
*
* Oct-86 TAW - use preferences baud rate only, and
* - other inutition based mods.
* 860823 DBW - Integrated and rewrote lots of code
* v2.0 860809 DBW - Major rewrite
* v1.1 860720 DBW - Switches, 80 cols, colors, bug fixes
* v1.0 860712 DBW - First version released
*
***************************************************************/
#include "vt100.h"
void InitDefaults (argc, argv)
char **argv;
int argc;
{
FILE *fd;
extern void ReadDefaults ();
if (((argc > 1) && (fd=fopen(argv[1],"r")) != 0) ||
(fd=fopen("vt100.init","r")) != 0 ||
(fd=fopen("c:vt100.init","r")) != 0) {
ReadDefaults(fd);
fclose(fd);
}
/* Now set up all the screen info as necessary */
MINY = 14;
p_lines = 24;
NewWindow.Height = (long)((p_lines*8)+8);
NewWindow.MinHeight = NewWindow.Height;
NewWindow.MaxHeight = NewWindow.Height;
NewWindow.TopEdge = 3;
MAXY = ((p_lines-1)*8) + MINY;
top = MINY;
bot = MAXY;
savx = MINX;
savy = MINY;
NewWindow.TopEdge = 0;
NewWindow.Screen = NULL;
NewWindow.Type = WBENCHSCREEN;
}
/*****************************************************************
*
* this function reads the file that contains the user defaults if
* the file was opened by InitDefault, it then modifies the p_ variables
* to the new values. This code is based on DBW's code, but I changed it
* a little, by removing a few things that I did not use.
*
* T Whelan Sept 1986
*
******************************************************************/
extern char *malloc();
void
ReadDefaults(fd)
FILE *fd;
{
char c0, delim, line[256], macro[256], *ptr;
int i, j, k;
while (fgets(line,256,fd) != 0) {
if ((c0 = line[0]) == '#') continue;
if ((c0|' ') == 'e') break;
if (sscanf(&line[1],"%d",&i) != 1) continue;
if (i < 1 || i > 10) continue;
delim = 0;
for (j=3; line[j] != 0 &&
(line[j] == ' ' || line[j] == '\t'); j++) ;
if (line[j] == 0) {
if (c0 == 'f') p_f[i-1] = NULL;
else p_F[i-1] = NULL;
break;
}
delim = line[j];
k = 0;
macro[0] = 0;
while (line[++j] != delim) {
if (line[j] == 0) {
if (fgets(line,256,fd) == 0) {
line[0] = delim;
line[1] = 0;
}
j = -1;
continue;
}
if (line[j] == '^' && line[++j] != '^')
macro[k++] = (line[j]|' ') - 0x60;
else if (line[j] != '\n') macro[k++] = line[j];
macro[k] = 0;
}
ptr = malloc(k+1);
if (c0 == 'f') p_f[i-1] = ptr;
else p_F[i-1] = ptr;
strcpy(ptr,macro);
}
}